home *** CD-ROM | disk | FTP | other *** search
- Path: dish.news.pipex.net!pipex!dircon!usenet
- From: sridgway@dircon.co.uk (Steven Ridgway)
- Newsgroups: comp.lang.c
- Subject: Re: CALL_BY_VALUE with ARRAYS ?
- Date: Mon, 11 Mar 1996 21:57:28 GMT
- Organization: Direct Connection
- Message-ID: <4i27r6$28m@newsgate.dircon.co.uk>
- References: <31442A98.41C6@dkfz-heidelberg.de>
- NNTP-Posting-Host: gw4-129.pool.dircon.co.uk
- X-Newsreader: Forte Free Agent 1.0.82
-
- Ramon Wartala <r.wartala@dkfz-heidelberg.de> wrote:
-
- >Hello World,
-
-
- >I've a problem which risks to break my nervs.
-
-
- >How can I call a function by a pointer, and giving her
- >a number of paramters which I don't know before executing ?
-
- >Exp.
-
- >Funcion :
-
- > int foo(char a, char b , char c) {}
-
-
- > void main()
- > {
- > int (*ptr)()=foo;
- > /* .... */
- > /* calling my function now ... */
- > (ptr)(a_variable);
- > /* ... while variable is a just a structure of 3 char. long */
- >}
-
-
- >The problem is, that I can define such a structure (e.g. by char
- >a_variable[3]), but if I try to give it to my function foo, the
- >compiler gives naturally only the reference of this 3-byte buffer
- >(which is totaly normal) to my function foo.
-
- >So my question could be explained with other words :
-
- >How can I force the compiler ( gcc for preference) to make a
- >call_by_value although with arrays ?
-
-
- >Thanks in advane for your help !
-
-
- >Jens
-
-
- >*** Jens Astor *****
- >*** jastor@jupiter.rz.fh-heilbronn.de *****
- >*** University of Heidelberg, Germany *****
-
- Hi,
-
- Why do you want to do this at all? Why not define foo to take a void *
- as its argument. Then cast this into whatever you want inside foo (ie
- an array of chars or whatever).
-
- Steven Ridgway (sridgway@dircon.co.uk)
-
-
-
-